package com.bt.lms.ui.action.teaching.plan.utils;

import com.bt.lms.network.msg.packet.ReqMsgPacket;

/**
 * 组包
 * @author 李舒淇
 */
public class EncodeReqMsgPacket {

    /**
     * 组包
     * @param reqMsgPacket 请求消息包
     * @return  数组
     */
    public static byte[] encodeReqMsgPacket(ReqMsgPacket reqMsgPacket) {


        //魔数
        byte[] magicNo = reqMsgPacket.getMagicNo();
        int length = magicNo.length;
        //协议版本号
        byte version = reqMsgPacket.getVersion();
        byte[] version1 = new byte[version];
        //序列化算法
        byte serialCou = reqMsgPacket.getSerialCou();
        byte[] serialCou1 = new byte[serialCou];
        //事件类型
        byte evenType = reqMsgPacket.getEvenType();
        byte[] evenType1 = new byte[evenType];
        //业务类型
        byte[] busType = reqMsgPacket.getBizType();
        int length1 = busType.length;
        //2Way
        byte twoWay = reqMsgPacket.getTwoWay();
        byte[] twoWay1 = new byte[twoWay];
        //请求id
        byte[] requestId = reqMsgPacket.getReqID();
        int length2 = requestId.length;
        //保留字段
        byte[] remainField = reqMsgPacket.getRemainField();
        int length3 = remainField.length;
        //数据长度
        byte[] dataLen = reqMsgPacket.getDataLen();
        int length4 = dataLen.length;
        //数据
        byte[] data = reqMsgPacket.getData();
        int length5 = data.length;



        byte[] bytes = MyByte.mergeByte(magicNo,version1,serialCou1,evenType1,busType,twoWay1,requestId,dataLen,data);





        return bytes;


    }

}
